<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Rrr extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $url = APPPATH . "libraries" . "/sinaweibo/saetv2.ex.class.php";
        $this->load->helper('url');
        $this->config->load('sns_openapi');
        require_once $url;
        $tsianconfig = $this->tsianconfig= $this->config->item('tsian');
        $this->o = new SaeTOAuthV2($tsianconfig["appkey"], $tsianconfig["secret"]);
        $this->code_url = $this->o->getAuthorizeURL($tsianconfig["call_back"]);
    }

    public function index() {
        $code_url = $this->code_url;
        redirect($code_url);
    }

    public function tsina_access_token() {
        
        print_r($_GET);
        $keys = array();
        $keys['code'] = $_GET['code'];
        $keys['redirect_uri'] = $this->code_url;
        print_r($this->o);
        echo $token = $this->o->getAccessToken('code', $keys);
    
        exit;


        if ($token) {
            $_SESSION['token'] = $token;
            setcookie('weibojs_' . $this->o->client_id, http_build_query($token));
        }



        print_r($_SESSION);



        exit;
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */